define("bmk/gui/skin", ["jquery", "bmk/util/debug"], function($, Debug) {
	
	var Skin = {};
	
	/**
	 * Add style link to the DOM 
	 */
	function addStyle(sUrl) {
		
		$("head").append('<link rel="stylesheet" href="' + sUrl + '" type="text/css">');
		
	}
	
	
	/**
	 * Load a BMK skin 
 	* @param {Object} sName
	 */
	Skin.Load = function(sName) {
	
		// Load skin configuration
		var skinPath = $.BMK.config.skinPath + sName + "/";
		$.ajax({
			url: skinPath + "config.json",
			data: "json"
		}).then(function(oConfig) {
			
			// Add reset stylesheet?
			if (oConfig.cssReset === true) {
				addStyle($.BMK.config.bmkPath + "css/reset.css");
			}
			
			// Loop through css files
			$.each(oConfig.css, function(index, css) {
				addStyle(skinPath + css);
			})

			
		}).fail(function(result) {
			Debug.warn("Failed to load skin '" + sName + "' from " + skinPath + "config.json");
		});
		
	}
	
	
	
	
	
	
	
	
	return Skin;
	
});
